package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TIntegralExchange;
import com.ruoyi.project.mahjong.service.ITIntegralExchangeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 积分兑换记录Controller
 * 
 * @author ruoyi
 * @date 2023-09-28
 */
@RestController
@RequestMapping("/mahjong/exchange")
public class TIntegralExchangeController extends BaseController
{
    @Autowired
    private ITIntegralExchangeService tIntegralExchangeService;

    /**
     * 查询积分兑换记录列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIntegralExchange tIntegralExchange)
    {
        startPage();
        List<TIntegralExchange> list = tIntegralExchangeService.selectTIntegralExchangeList(tIntegralExchange);
        return getDataTable(list);
    }

    /**
     * 导出积分兑换记录列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:export')")
    @Log(title = "积分兑换记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TIntegralExchange tIntegralExchange)
    {
        List<TIntegralExchange> list = tIntegralExchangeService.selectTIntegralExchangeList(tIntegralExchange);
        ExcelUtil<TIntegralExchange> util = new ExcelUtil<TIntegralExchange>(TIntegralExchange.class);
        return util.exportExcel(list, "exchange");
    }

    /**
     * 获取积分兑换记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tIntegralExchangeService.selectTIntegralExchangeById(id));
    }

    /**
     * 新增积分兑换记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:add')")
    @Log(title = "积分兑换记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIntegralExchange tIntegralExchange)
    {
        return toAjax(tIntegralExchangeService.insertTIntegralExchange(tIntegralExchange));
    }

    /**
     * 修改积分兑换记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:edit')")
    @Log(title = "积分兑换记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIntegralExchange tIntegralExchange)
    {
        return toAjax(tIntegralExchangeService.updateTIntegralExchange(tIntegralExchange));
    }

    /**
     * 删除积分兑换记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:exchange:remove')")
    @Log(title = "积分兑换记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tIntegralExchangeService.deleteTIntegralExchangeByIds(ids));
    }
}
